package com.leyou.page.web;

import com.leyou.page.service.GoodsPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.Id;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("page")
public class PageController {
    @Autowired
    private GoodsPageService goodsPageService;

    /**
     * 查询商品Spu的数据
     * @param spuId
     * @return
     */
    @GetMapping("/spu/{id}")
    public ResponseEntity<String> querySpuPageData(@PathVariable("id") Long spuId){
        return ResponseEntity.ok(goodsPageService.loadBrandData(spuId));
    }

    /**
     * 查询商品sku数据
     * @param spuId
     * @return
     */
    @GetMapping("/sku/{id}")
    public ResponseEntity<String> querySkuPageData(@PathVariable("id") Long spuId){
        return ResponseEntity.ok(goodsPageService.loadSkuListData(spuId));
    }

    /**
     * 查询商品spuDetail数据
     * @param spuId 商品id
     * @return spu数据
     */
    @GetMapping("/detail/{id}")
    public ResponseEntity<String> querDetailPAgeData(@PathVariable("id") Long spuId){
        return ResponseEntity.ok(goodsPageService.loadSpuDetailData(spuId));
    }

    /**
     * 查询商品分类数据
     * @param ids
     * @return
     */
    @GetMapping("/categories")
    public ResponseEntity<String>queryCategoryPageData (@RequestParam("ids") List<Long>ids){
        return ResponseEntity.ok(goodsPageService.loadCategoriesData(ids));

    }

    /**
     * 查询规格参数
     * @param id  品牌id
     * @return
     */
    @GetMapping("/brand/{id}")
    public ResponseEntity<String> queryBrandPageData(@PathVariable("id") Long id){
        return ResponseEntity.ok(goodsPageService.loadBrandData(id));
    }

    @GetMapping("/spec/{id}")
    public ResponseEntity<String> queryGoodsPageData(@PathVariable("id") Long categoryId){

        return ResponseEntity.ok(goodsPageService.loadSpecData(categoryId));
    }

}
